package com.mianshi;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Solution3 {

    // todo: 定义一个 map 用来记录 数组元素 和 下标
    // todo: 遍历map的 get(key) 和get(target - key) 都不为空, 就输出

    // todo: 方法定义的返回值改了
    int[][] calc(int[] num, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < num.length; i++) {
            map.put(num[i], i); // map的key是数组元素, value是数组下标
        }
        List<int[]> ans = new ArrayList<>();
        for (int i : num) {
            // 如果都不为空
            if (map.get(i) != null && map.get(target - i) != null) {
                ans.add(new int[]{map.get(i), map.get(target - i)});
            }
        }
        int[][] ansArr = new int[ans.size()][2];
        for (int i = 0; i < ans.size(); i++) {
            ansArr[i] = ans.get(i);
        }
        return ansArr; // todo: 方法定义的返回值改了
    }

    @Test
    public void test() {
        String str = "114.01250593950832 22.56814637684731";
        double x = Double.valueOf(str.split(" ")[0]);
        double y = Double.valueOf(str.split(" ")[1]);
        System.out.println("{\"args\":[{\"contextMap\":{\"JOB_VERSION_INIT\":\"1\",\"tianMaContext\":\"{\\\"callbackTopic\\\":\\\"tianma-xmap-flow-center-callback_DAILY\\\",\\\"flowContext\\\":\\\"3787424542079#task_6Cy3yJ#3787424582079#xmap-flow-center\\\",\\\"callbackTag\\\":\\\"callback\\\"}\",\"schedulerConfig\":\"{\\\"callbackTopic\\\":\\\"xmap-skywalker-scheduler-job-callback-daily\\\",\\\"defaultTaskType\\\":\\\"currentSituationEvalSolidData\\\"}\",\"PHASE_BRIDGE_TYPE_preHandle\":\"syncWait\"},\"resultMap\":{},\"signature\":\"130510690##currentSituationEvaluationSolidJob##daily##currentSituationEvalSolidPrepareParamHandler##actualHandle\",\"skywalkerJobInfo\":{\"beginTime\":20240514234546525,\"businessKey\":\"5252933\",\"dataId\":\"5252933\",\"endTime\":20240514234554908,\"env\":\"daily\",\"execCount\":11,\"expectExecTime\":20240514223639644,\"gmtCreate\":20240514223639723,\"gmtModified\":20240514234555498,\"jobId\":130510690,\"jobType\":\"currentSituationEvaluationSolidJob\",\"priority\":0,\"rkId\":2556762489068978176,\"runnerIp\":\"11.123.64.87\",\"sceneType\":\"current-situation-evaluate-solid-flow\",\"status\":2,\"subBusinessKey\":\"5252933\",\"tenantCode\":\"xmap-zll-platform\"}}],\"asynchronouInvok\":false,\"env\":\"daily\",\"methodName\":\"currentSituationEvalSolidPrepareParamHandler\",\"parameterType\":[\"com.autonavi.xmap.skywalker.open.model.SkywalkerJobHandlerParams\"],\"projectName\":\"xmap-hq-quality-evaluate\",\"runnerName\":\"hqProductQualityRunner\"}");
    }

    @Test
    public void test2() {
        String str = "78\n" +
                "79\n" +
                "80\n" +
                "81\n" +
                "82\n" +
                "83\n" +
                "84\n" +
                "85\n" +
                "86\n" +
                "87\n" +
                "88\n" +
                "89\n" +
                "90\n" +
                "91\n" +
                "92\n" +
                "93\n" +
                "94\n" +
                "95\n" +
                "96\n" +
                "97\n" +
                "98\n" +
                "99\n" +
                "100\n" +
                "101\n" +
                "102\n" +
                "103\n" +
                "104\n" +
                "105\n" +
                "106\n" +
                "107\n" +
                "108\n" +
                "109\n" +
                "110\n" +
                "111\n" +
                "112\n" +
                "113\n" +
                "114\n" +
                "115\n" +
                "116\n" +
                "117\n" +
                "118\n" +
                "119\n" +
                "120\n" +
                "121\n" +
                "122\n" +
                "123\n" +
                "124\n" +
                "125\n" +
                "126\n" +
                "127\n" +
                "128\n" +
                "129\n" +
                "130\n" +
                "131";
        System.out.println(str);
    }



}
